using System;
using System.ComponentModel;
using System.Threading;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.EventArgs;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.Interfaces;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.Respondents;

namespace FU.Capstones.IMS.Web.Common.InventoryServiceProxy.OperationContracts
{
    public partial class InventoryServiceClient
    {

        #region GetEmployeeCollection

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Employee>> GetEmployeeCollectionCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginGetEmployeeCollection(bool isShowAll, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginGetEmployeeCollection(isShowAll, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        CollectionFeedback<Employee> IInventoryService.EndGetEmployeeCollection(IAsyncResult result)
        {
            return Channel.EndGetEmployeeCollection(result);
        }

        private IAsyncResult OnBeginGetEmployeeCollection(object[] inValues, AsyncCallback callback, object asyncState)
        {
            bool isShowAll = (bool)inValues[0];

            return ((IInventoryService)(this)).BeginGetEmployeeCollection(isShowAll, callback, asyncState);
        }

        private object[] OnEndGetEmployeeCollection(IAsyncResult result)
        {
            CollectionFeedback<Employee> retVal = ((IInventoryService)(this)).EndGetEmployeeCollection(result);
            return new object[] { retVal };
        }

        private void OnGetEmployeeCollectionCompleted(object state)
        {
            if ((GetEmployeeCollectionCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                GetEmployeeCollectionCompleted(this, new CollectionFeedbackCompletedEventArgs<Employee>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetEmployeeCollectionAsync(bool isShowAll)
        {
            GetEmployeeCollectionAsync(isShowAll, null);
        }

        public void GetEmployeeCollectionAsync(bool isShowAll, object userState)
        {
            if ((onBeginGetEmployeeCollectionDelegate == null))
            {
                onBeginGetEmployeeCollectionDelegate = new BeginOperationDelegate(OnBeginGetEmployeeCollection);
            }
            if ((onEndGetEmployeeCollectionDelegate == null))
            {
                onEndGetEmployeeCollectionDelegate = new EndOperationDelegate(OnEndGetEmployeeCollection);
            }
            if ((onGetEmployeeCollectionCompletedDelegate == null))
            {
                onGetEmployeeCollectionCompletedDelegate = new SendOrPostCallback(OnGetEmployeeCollectionCompleted);
            }
            InvokeAsync(onBeginGetEmployeeCollectionDelegate, new object[] {
                    isShowAll}, onEndGetEmployeeCollectionDelegate, onGetEmployeeCollectionCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginGetEmployeeCollectionDelegate;

        private EndOperationDelegate onEndGetEmployeeCollectionDelegate;

        private SendOrPostCallback onGetEmployeeCollectionCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginGetEmployeeCollection(bool isShowAll, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = isShowAll;

                IAsyncResult _result = BeginInvoke("GetEmployeeCollection", _args, callback, asyncState);
                return _result;
            }

            public CollectionFeedback<Employee> EndGetEmployeeCollection(IAsyncResult result)
            {
                object[] _args = new object[0];
                CollectionFeedback<Employee> _result = ((CollectionFeedback<Employee>)(EndInvoke("GetEmployeeCollection", _args, result)));
                return _result;
            }
        }

        #endregion
        
        #region GetSingleEmployee

        public event EventHandler<SingleFeedbackCompletedEventArgs<Employee>> GetSingleEmployeeCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginGetSingleEmployee(int objectID, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginGetSingleEmployee(objectID, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        SingleFeedback<Employee> IInventoryService.EndGetSingleEmployee(IAsyncResult result)
        {
            return Channel.EndGetSingleEmployee(result);
        }

        private IAsyncResult OnBeginGetSingleEmployee(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int objectID = (int)inValues[0];

            return ((IInventoryService)(this)).BeginGetSingleEmployee(objectID, callback, asyncState);
        }

        private object[] OnEndGetSingleEmployee(IAsyncResult result)
        {
            SingleFeedback<Employee> retVal = ((IInventoryService)(this)).EndGetSingleEmployee(result);
            return new object[] { retVal };
        }

        private void OnGetSingleEmployeeCompleted(object state)
        {
            if ((GetSingleEmployeeCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                GetSingleEmployeeCompleted(this, new SingleFeedbackCompletedEventArgs<Employee>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetSingleEmployeeAsync(int objectID)
        {
            GetSingleEmployeeAsync(objectID, null);
        }

        public void GetSingleEmployeeAsync(int objectID, object userState)
        {
            if ((onBeginGetSingleEmployeeDelegate == null))
            {
                onBeginGetSingleEmployeeDelegate = new BeginOperationDelegate(OnBeginGetSingleEmployee);
            }
            if ((onEndGetSingleEmployeeDelegate == null))
            {
                onEndGetSingleEmployeeDelegate = new EndOperationDelegate(OnEndGetSingleEmployee);
            }
            if ((onGetSingleEmployeeCompletedDelegate == null))
            {
                onGetSingleEmployeeCompletedDelegate = new SendOrPostCallback(OnGetSingleEmployeeCompleted);
            }
            InvokeAsync(onBeginGetSingleEmployeeDelegate, new object[] {
                                                                                   objectID}, onEndGetSingleEmployeeDelegate, onGetSingleEmployeeCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginGetSingleEmployeeDelegate;

        private EndOperationDelegate onEndGetSingleEmployeeDelegate;

        private SendOrPostCallback onGetSingleEmployeeCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginGetSingleEmployee(int objectID, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = objectID;

                IAsyncResult _result = BeginInvoke("GetSingleEmployee", _args, callback, asyncState);
                return _result;
            }

            public SingleFeedback<Employee> EndGetSingleEmployee(IAsyncResult result)
            {
                object[] _args = new object[0];
                SingleFeedback<Employee> _result = ((SingleFeedback<Employee>)(EndInvoke("GetSingleEmployee", _args, result)));
                return _result;
            }
        }

        #endregion

        #region InsertEmployee

        public event EventHandler<SingleFeedbackCompletedEventArgs<int>> InsertEmployeeCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginInsertEmployee(Employee data, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginInsertEmployee(data, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        SingleFeedback<int> IInventoryService.EndInsertEmployee(IAsyncResult result)
        {
            return Channel.EndInsertEmployee(result);
        }

        private IAsyncResult OnBeginInsertEmployee(object[] inValues, AsyncCallback callback, object asyncState)
        {
            Employee data = (Employee)inValues[0];

            return ((IInventoryService)(this)).BeginInsertEmployee(data, callback, asyncState);
        }

        private object[] OnEndInsertEmployee(IAsyncResult result)
        {
            SingleFeedback<int> retVal = ((IInventoryService)(this)).EndInsertEmployee(result);
            return new object[] { retVal };
        }

        private void OnInsertEmployeeCompleted(object state)
        {
            if ((InsertEmployeeCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                InsertEmployeeCompleted(this, new SingleFeedbackCompletedEventArgs<int>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void InsertEmployeeAsync(Employee data)
        {
            InsertEmployeeAsync(data, null);
        }

        public void InsertEmployeeAsync(Employee data, object userState)
        {
            if ((onBeginInsertEmployeeDelegate == null))
            {
                onBeginInsertEmployeeDelegate = new BeginOperationDelegate(OnBeginInsertEmployee);
            }
            if ((onEndInsertEmployeeDelegate == null))
            {
                onEndInsertEmployeeDelegate = new EndOperationDelegate(OnEndInsertEmployee);
            }
            if ((onInsertEmployeeCompletedDelegate == null))
            {
                onInsertEmployeeCompletedDelegate = new SendOrPostCallback(OnInsertEmployeeCompleted);
            }
            InvokeAsync(onBeginInsertEmployeeDelegate, new object[] {
                                                                                data}, onEndInsertEmployeeDelegate, onInsertEmployeeCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginInsertEmployeeDelegate;

        private EndOperationDelegate onEndInsertEmployeeDelegate;

        private SendOrPostCallback onInsertEmployeeCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginInsertEmployee(Employee data, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = data;

                IAsyncResult _result = BeginInvoke("InsertEmployee", _args, callback, asyncState);
                return _result;
            }

            public SingleFeedback<int> EndInsertEmployee(IAsyncResult result)
            {
                object[] _args = new object[0];
                SingleFeedback<int> _result = ((SingleFeedback<int>)(EndInvoke("InsertEmployee", _args, result)));
                return _result;
            }
        }

        #endregion

        #region UpdateEmployee

        public event EventHandler<FeedbackCompletedEventArgs> UpdateEmployeeCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginUpdateEmployee(Employee data, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginUpdateEmployee(data, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndUpdateEmployee(IAsyncResult result)
        {
            return Channel.EndUpdateEmployee(result);
        }

        private IAsyncResult OnBeginUpdateEmployee(object[] inValues, AsyncCallback callback, object asyncState)
        {
            Employee data = (Employee)inValues[0];

            return ((IInventoryService)(this)).BeginUpdateEmployee(data, callback, asyncState);
        }

        private object[] OnEndUpdateEmployee(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndUpdateEmployee(result);
            return new object[] { retVal };
        }

        private void OnUpdateEmployeeCompleted(object state)
        {
            if ((UpdateEmployeeCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                UpdateEmployeeCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void UpdateEmployeeAsync(Employee data)
        {
            UpdateEmployeeAsync(data, null);
        }

        public void UpdateEmployeeAsync(Employee data, object userState)
        {
            if ((onBeginUpdateEmployeeDelegate == null))
            {
                onBeginUpdateEmployeeDelegate = new BeginOperationDelegate(OnBeginUpdateEmployee);
            }
            if ((onEndUpdateEmployeeDelegate == null))
            {
                onEndUpdateEmployeeDelegate = new EndOperationDelegate(OnEndUpdateEmployee);
            }
            if ((onUpdateEmployeeCompletedDelegate == null))
            {
                onUpdateEmployeeCompletedDelegate = new SendOrPostCallback(OnUpdateEmployeeCompleted);
            }
            InvokeAsync(onBeginUpdateEmployeeDelegate, new object[] {
                                                                                data}, onEndUpdateEmployeeDelegate, onUpdateEmployeeCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginUpdateEmployeeDelegate;

        private EndOperationDelegate onEndUpdateEmployeeDelegate;

        private SendOrPostCallback onUpdateEmployeeCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginUpdateEmployee(Employee data, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = data;

                IAsyncResult _result = BeginInvoke("UpdateEmployee", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndUpdateEmployee(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("UpdateEmployee", _args, result)));
                return _result;
            }
        }

        #endregion

        #region DeleteEmployee

        public event EventHandler<FeedbackCompletedEventArgs> DeleteEmployeeCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginDeleteEmployee(int data, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginDeleteEmployee(data, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndDeleteEmployee(IAsyncResult result)
        {
            return Channel.EndDeleteEmployee(result);
        }

        private IAsyncResult OnBeginDeleteEmployee(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int data = (int)inValues[0];

            return ((IInventoryService)(this)).BeginDeleteEmployee(data, callback, asyncState);
        }

        private object[] OnEndDeleteEmployee(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndDeleteEmployee(result);
            return new object[] { retVal };
        }

        private void OnDeleteEmployeeCompleted(object state)
        {
            if ((DeleteEmployeeCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                DeleteEmployeeCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void DeleteEmployeeAsync(int data)
        {
            DeleteEmployeeAsync(data, null);
        }

        public void DeleteEmployeeAsync(int data, object userState)
        {
            if ((onBeginDeleteEmployeeDelegate == null))
            {
                onBeginDeleteEmployeeDelegate = new BeginOperationDelegate(OnBeginDeleteEmployee);
            }
            if ((onEndDeleteEmployeeDelegate == null))
            {
                onEndDeleteEmployeeDelegate = new EndOperationDelegate(OnEndDeleteEmployee);
            }
            if ((onDeleteEmployeeCompletedDelegate == null))
            {
                onDeleteEmployeeCompletedDelegate = new SendOrPostCallback(OnDeleteEmployeeCompleted);
            }
            InvokeAsync(onBeginDeleteEmployeeDelegate, new object[] {
                                                                                data}, onEndDeleteEmployeeDelegate, onDeleteEmployeeCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginDeleteEmployeeDelegate;

        private EndOperationDelegate onEndDeleteEmployeeDelegate;

        private SendOrPostCallback onDeleteEmployeeCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginDeleteEmployee(int data, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = data;

                IAsyncResult _result = BeginInvoke("DeleteEmployee", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndDeleteEmployee(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("DeleteEmployee", _args, result)));
                return _result;
            }
        }

        #endregion

        #region SearchEmployee

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Employee>> SearchEmployeeCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginSearchEmployee(EmployeeCriteria criteria, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginSearchEmployee(criteria, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        CollectionFeedback<Employee> IInventoryService.EndSearchEmployee(IAsyncResult result)
        {
            return Channel.EndSearchEmployee(result);
        }

        private IAsyncResult OnBeginSearchEmployee(object[] inValues, AsyncCallback callback, object asyncState)
        {
            EmployeeCriteria criteria = (EmployeeCriteria)inValues[0];

            return ((IInventoryService)(this)).BeginSearchEmployee(criteria, callback, asyncState);
        }

        private object[] OnEndSearchEmployee(IAsyncResult result)
        {
            CollectionFeedback<Employee> retVal = ((IInventoryService)(this)).EndSearchEmployee(result);
            return new object[] { retVal };
        }

        private void OnSearchEmployeeCompleted(object state)
        {
            if ((SearchEmployeeCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                SearchEmployeeCompleted(this, new CollectionFeedbackCompletedEventArgs<Employee>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void SearchEmployeeAsync(EmployeeCriteria criteria)
        {
            SearchEmployeeAsync(criteria, null);
        }

        public void SearchEmployeeAsync(EmployeeCriteria criteria, object userState)
        {
            if ((onBeginSearchEmployeeDelegate == null))
            {
                onBeginSearchEmployeeDelegate = new BeginOperationDelegate(OnBeginSearchEmployee);
            }
            if ((onEndSearchEmployeeDelegate == null))
            {
                onEndSearchEmployeeDelegate = new EndOperationDelegate(OnEndSearchEmployee);
            }
            if ((onSearchEmployeeCompletedDelegate == null))
            {
                onSearchEmployeeCompletedDelegate = new SendOrPostCallback(OnSearchEmployeeCompleted);
            }
            InvokeAsync(onBeginSearchEmployeeDelegate, new object[] {
                                                                                criteria}, onEndSearchEmployeeDelegate, onSearchEmployeeCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginSearchEmployeeDelegate;

        private EndOperationDelegate onEndSearchEmployeeDelegate;

        private SendOrPostCallback onSearchEmployeeCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginSearchEmployee(EmployeeCriteria criteria, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = criteria;

                IAsyncResult _result = BeginInvoke("SearchEmployee", _args, callback, asyncState);
                return _result;
            }

            public CollectionFeedback<Employee> EndSearchEmployee(IAsyncResult result)
            {
                object[] _args = new object[0];
                CollectionFeedback<Employee> _result = ((CollectionFeedback<Employee>)(EndInvoke("SearchEmployee", _args, result)));
                return _result;
            }
        }

        #endregion

        #region UndoDeleteEmployee

        public event EventHandler<FeedbackCompletedEventArgs> UndoDeleteEmployeeCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginUndoDeleteEmployee(int objID, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginUndoDeleteEmployee(objID, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndUndoDeleteEmployee(IAsyncResult result)
        {
            return Channel.EndUndoDeleteEmployee(result);
        }

        private IAsyncResult OnBeginUndoDeleteEmployee(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int objID = (int)inValues[0];

            return ((IInventoryService)(this)).BeginUndoDeleteEmployee(objID, callback, asyncState);
        }

        private object[] OnEndUndoDeleteEmployee(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndUndoDeleteEmployee(result);
            return new object[] { retVal };
        }

        private void OnUndoDeleteEmployeeCompleted(object state)
        {
            if ((UndoDeleteEmployeeCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                UndoDeleteEmployeeCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void UndoDeleteEmployeeAsync(int objID)
        {
            UndoDeleteEmployeeAsync(objID, null);
        }

        public void UndoDeleteEmployeeAsync(int objID, object userState)
        {
            if ((onBeginUndoDeleteEmployeeDelegate == null))
            {
                onBeginUndoDeleteEmployeeDelegate = new BeginOperationDelegate(OnBeginUndoDeleteEmployee);
            }
            if ((onEndUndoDeleteEmployeeDelegate == null))
            {
                onEndUndoDeleteEmployeeDelegate = new EndOperationDelegate(OnEndUndoDeleteEmployee);
            }
            if ((onUndoDeleteEmployeeCompletedDelegate == null))
            {
                onUndoDeleteEmployeeCompletedDelegate = new SendOrPostCallback(OnUndoDeleteEmployeeCompleted);
            }
            InvokeAsync(onBeginUndoDeleteEmployeeDelegate, new object[] {
                    objID}, onEndUndoDeleteEmployeeDelegate, onUndoDeleteEmployeeCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginUndoDeleteEmployeeDelegate;

        private EndOperationDelegate onEndUndoDeleteEmployeeDelegate;

        private SendOrPostCallback onUndoDeleteEmployeeCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginUndoDeleteEmployee(int objID, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = objID;

                IAsyncResult _result = BeginInvoke("UndoDeleteEmployee", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndUndoDeleteEmployee(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("UndoDeleteEmployee", _args, result)));
                return _result;
            }
        }

        #endregion
        

    }
}